<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/**
 * 打印函数
 * @param $var
 */
function p($var){
    echo '<pre style="background: #cccccc;color: red">';
    if (is_bool($var)){
        var_dump($var);
    }else if (is_null($var)){
        echo 'NULL';
    }else{
        print_r($var);
    }
    echo '<pre>';
    exit;
}

/**
 * 密码加密函数
 * @param string $str
 * @return string
 */
function get_md5_str($str=''){
    return $str==''?'':md5(sha1($str));
}


function getTreeData($data,$parentid,$cid,$pid=0){
    $tree = [];
    foreach ($data as $v){
        if ($v[$parentid]==$pid){
            $v['child'] = getTreeData($data,$parentid,$cid,$v[$cid]);
            $tree[]=$v;
        }

    }
    return $tree;
}